// -*- c++ -*-
// Copyright 2008 Isis Innovation Limited
//
// MapViewer.h
//
// Defines the MapViewer class
//
// This defines a simple map viewer widget, which can draw the 
// current map and the camera/keyframe poses within it.
//
#ifndef __MAP_VIEWER_H
#define __MAP_VIEWER_H

#include "Map.h"
#include "ATANCamera.h"
#include <TooN/TooN.h>
#include <gvars3/instances.h>
using namespace TooN;
#include <TooN/se3.h>
#include <sstream>
#include <vector>
#include "GLWindow2.h"
#include "KeyFrame.h"

class Map;

class MapViewer
{
public:
  MapViewer(const ATANCamera &c, GLWindow2 &glw);
  void DrawMap(Map *pMap, SE3<> se3CamFromWorld, std::vector<TooN::Vector<3> > &vTest);
  std::string GetMessageForUser();
  
protected:
  ATANCamera mCamera;
  GLWindow2 &mGLWindow;
  
  void DrawGrid();
  void DrawCamera(SE3<> se3);
  void DrawMesh(Map *pMap);
  void DrawMapDots(Map *pMap, SE3<> se3CfromW, std::vector<TooN::Vector<3> > &vTest);
  void DrawKeyFrames(Map *pMap);
  void DrawKeyFrame(Map *pMap, boost::shared_ptr<KeyFrame> kf);
  void SetupFrustum();
  void SetupModelView(SE3<> se3WorldFromCurrent = SE3<>());

  int mnGlobalSE3;      // Should we use provided external position estimate (absolute measurements from GPS)
  int mnGlobalSO3;      // Should we use provided external attitude estimate (absolute measurements from compass, gyros etc.)
  int mnDrawGlobal;      // Should we use provided external attitude estimate (absolute measurements from compass, gyros etc.)
  GVars3::gvar3<int> mgvnGlobalSE3;
  GVars3::gvar3<int> mgvnGlobalSO3;
  GVars3::gvar3<int> mgvnDrawGlobal;
  
  Vector<3> mv3MassCenter;
  SE3<> mse3ViewerFromWorld;

  std::ostringstream mMessageForUser;
};

#endif
